#pragma once
#include "defs.h"
#include "Vector.h"

namespace vivid
{
    class Vector;

    class Normal
    {
    public:
        Normal() : _x(0), _y(0), _z(0) {}
        Normal(VFloat aX, VFloat aY, VFloat aZ) 
            : _x(aX), _y(aY), _z(aZ) {}
        Normal(Normal const & aNorm) 
            : _x(aNorm._x), _y(aNorm._y), _z(aNorm._z) {}
        explicit Normal(Vector const & aVec)
        {
            Vector n(aVec.Normalize());

            _x = n._x;
            _y = n._y;
            _z = n._z;
        }

        VFloat Dot(Normal const & aN) const;
        Normal Cross(Normal const & aN) const;
        Vector operator *(VFloat aNum) const;
        Vector operator /(VFloat aNum) const;
        

        VFloat _x;
        VFloat _y;
        VFloat _z;
    };


    VFloat Normal::Dot(Normal const & aN) const
    {
        return _x * aN._x + _y * aN._y + _z * aN._z;
    }


    Normal Normal::Cross(Normal const & aN) const
    {
        return Normal(
            _y * aN._z - _z * aN._y,
            _x * aN._z - _z * aN._x,
            _x * aN._y - _y * aN._x);
    }


    Vector Normal::operator *(VFloat aNum) const
    {
        return Vector(
            _x * aNum,
            _y * aNum,
            _z * aNum);
    }


    Vector Normal::operator /(VFloat aNum) const
    {
        VFloat n = 1.0 / aNum;

        return Vector(
            _x * n,
            _y * n,
            _z * n);
	}
};